package cn.UploadLog;

import cn.GetPath.accessPath;
import cn.batchDelete.batchD;
import cn.dto.Basiclfor;
import cn.dto.BizConstant;
import cn.hutool.http.HttpRequest;
import cn.utils.GuideTable;
import cn.utils.ReadTxt;
import cn.utils.Surface;
import com.alibaba.fastjson.JSONObject;
import org.apache.log4j.Logger;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;

public class day {

    private static Logger log4j = Logger.getLogger(day.class);
    private static final AtomicInteger deviceCount = new AtomicInteger();

    public static void main(String[] args) {
        BizConstant bizConstant = ReadTxt.readFile(accessPath.getTxt());




        Surface surface = new Surface();
        ArrayList<Basiclfor> test = surface.test(accessPath.getXlsx());


        String upl_url = bizConstant.getUPL_URL();
        test.forEach(e -> {
            String stuString = JSONObject.toJSONString(e);
            System.out.println(stuString);

            String resp = HttpRequest.post("http:" + upl_url + ":8000/api-devicelog-collect/data/NonLoraData?dataCode&deviceId&postTime&data")
                    .body(stuString).execute().body();
            log4j.info(resp);
            deviceCount.incrementAndGet();
        });
        log4j.info("累计上传次数"+deviceCount);
    }


}
